<?php

class Core_Controller_Admincp_Hook_Delete extends Nuo_Controller_Admincp
{
	function execute($request)
	{
		$id = $request -> getParam('hook_id');

		$table = Nuo::getTable('core/hook');

		$form = Nuo::getObject('core/admincp/hook/delete', 'form');

		$item = NULL;

		if ($id)
		{
			$item = $table -> find($id) -> current();
		}

		if ($request -> isGet() && $item)
		{
			$form -> setData($item -> toArray());
		}

		if ($request -> isPost() && $form -> isValid($_POST))
		{
			$data = $form -> getData();

			$item -> delete();

			Nuo_Messenger::instance()->add(Intl::__('Updated!'));

			return  array('jscript' => 'nuo.refresh()');

			return;
		}

		return  Nuo::getView()->render('core/view/controller/admincp/edit', array('form' => $form));
	}

}
